<template>
  <div>
    <el-form :model="form" ref="form" label-width="80px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="工号" prop="staffNo">
            <el-input v-model="form.staffNo" placeholder="请输入工号" :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="姓名" prop="name">
            <el-input v-model="form.name" placeholder="请输入姓名" :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="部门" prop="userDeptName">
            <el-input v-model="form.userDeptName" placeholder="请输入考生部门" :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="题库" prop="questionBankName">
            <el-input v-model="form.questionBankName" :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目代码" prop="projectCode">
            <el-input v-model="form.projectCode" size="small" :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目名称" prop="projectName">
            <el-input v-model="form.projectName" size="small" :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="考场" prop="examPlanDTO.examRoomId" v-if="form.examPlanDTO.examRoomId !== null ? true : false">
            <el-input v-model="examRoomName" size="small" :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="考试时间" prop="examPlanDTO.examDate" v-if="form.examPlanDTO.examDate !== null ? true : false">
            <el-input v-model="form.examPlanDTO.examDate+' '+form.examPlanDTO.examStart+'~'+form.examPlanDTO.examEnd" size="small" :disabled="true"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="取证状态" prop="obtainEvidenceStatus">
            <el-select v-model="form.obtainEvidenceStatus" placeholder="请选择取证状态" size="small" :disabled="true" style="width: 100%;">
              <el-option
                v-for="dict in obtainEvidenceStatusOptions"
                :key="dict.code"
                :label="dict.name"
                :value="dict.code"
              />
            </el-select>
          </el-form-item>
        </el-col>
          <el-col :span="12">
            <el-form-item label="是否补考">
              <el-radio-group v-model="form.isSignUp"  :disabled="true">
                <el-radio :label="'0'">是</el-radio>
                <el-radio :label="'1'">否</el-radio>
              </el-radio-group>
            </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="取消原因" prop="cancelCause" v-if="cancelOpen">
        <el-input v-model="form.cancelCause" type="textarea" :disabled="true"/>
      </el-form-item>
      <el-form-item label="取消日期" prop="postponeDate" v-if="cancelOpen">
        <el-date-picker
          v-model="form.cancelDate"
          clearable
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="date"
          placeholder="取消日期"
          :disabled="true"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="延期原因" prop="postponeCause" v-if="postponeOpen">
        <el-input v-model="form.postponeCause" type="textarea":disabled="true" />
      </el-form-item>
      <el-form-item label="延期日期" prop="postponeDate" v-if="postponeOpen">
        <el-date-picker
          v-model="form.postponeDate"
          clearable
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="date"
          placeholder="延期日期"
          :disabled="true"
        ></el-date-picker>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer" style="float: right;">
      <el-button size="mini" @click="cancel">关 闭</el-button>
    </div>
  </div>
</template>

<script>
  import {getExamRoomList} from "@/api/exam/examRoom";

  export default {
    name: "signUp",
    props: {
      form: Object,
      //取消原因开关
      cancelOpen: Boolean,
      //延期原因开关
      postponeOpen: Boolean,
    },
    data() {
      return {
        //取值状态
        obtainEvidenceStatusOptions: [],
        // 考场列表数据
        examRoomList: [],
        // 考场名称
        examRoomName: '',
      }
    },
    created() {
      //取值状态
      this.getDicts("exam_obtain_evidence_status").then(response => {
        this.obtainEvidenceStatusOptions = response.responseBody.result;
      })
      //    初始化考场列表
      this.getRoomList();
    },
    methods: {
      //查询考场信息
      getRoomList(){
        getExamRoomList({
          'pageParameter': {"page":1,"rows":1000},
          'searchParams': {}
        }).then(response => {
          this.examRoomList = response.responseBody.result;
          // 获取考场名称
          if (this.form.examPlanDTO.examRoomId !== null) {
            var examRoomName = this.examRoomFormat(this.form.examPlanDTO);
            // console.log("examRoomName==:",examRoomName);
            this.examRoomName = examRoomName;
          }
        })
      },
      // 考场翻译
      examRoomFormat(row, column) {
        const examRoomId = row.examRoomId;
        // console.log("= 考场Id ==",examRoomId);
        // 考场列表
        const datas = this.examRoomList;
        var actions = [];
        Object.keys(datas).some((key) => {
          if (datas[key].examRoomId == (examRoomId)) {
            actions.push(datas[key].examRoomName);
            return true;
          }
        })
        return actions.join('');
      },
      //关闭dialog
      cancel() {
        this.$emit("cancelDialog");
      }
    }
  }
</script>

<style scoped>

</style>
